home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Peter Lewis / Finger 1.3.5 / source / My Units / MyGrowZones.unit < prev    next >
Encoding:
Text File  |  1992-02-24  |  1.4 KB  |  77 lines  |  [TEXT/PJMM]

  1. unit MyGrowZones;
  2.  
  3. { This code is part of the Finger/Fingerd source code, written in THINK Pascal 4 }
  4. { Copyright 1991-1992 Peter N Lewis }
  5. { If you use this code, you must give me credit in your about box and documentation }
  6. { This is part of my generic library of routines }
  7.  
  8. interface
  9.  
  10.     procedure InitGrowZone (alertid: integer);
  11.     procedure FinishGrowZone;
  12.     procedure GrowZoneIdle;
  13.     function MemoryCritical: boolean;
  14.  
  15. implementation
  16.  
  17.     uses
  18.         BaseGlobals;
  19.  
  20.     var
  21.         gzh: handle;
  22.         lastgzh: handle;
  23.         id: integer;
  24.  
  25.     function MyGrowZone (size: longInt): longInt;
  26.     begin
  27.         if gzh <> nil then begin
  28.             MyGrowZone := GetHandleSize(gzh);
  29.             DisposHandle(gzh);
  30.             gzh := nil;
  31.         end
  32.         else
  33.             MyGrowZone := 0;
  34.     end;
  35.  
  36.     procedure GrowZoneIdle;
  37.         var
  38.             t, c: longInt;
  39.             a: integer;
  40.     begin
  41.         if gzh = nil then begin
  42.             PurgeSpace(t, c);
  43.             if c > growzone_size then
  44.                 gzh := NewHandle(growzone_size);
  45.             if (gzh = nil) and (lastgzh <> nil) then begin
  46.                 SetCursor(arrow);
  47.                 a := Alert(id, nil);
  48.             end;
  49.             lastgzh := gzh;
  50.         end;
  51.     end;
  52.  
  53.     function MemoryCritical: boolean;
  54.     begin
  55.         MemoryCritical := gzh = nil;
  56.     end;
  57.  
  58. {$S Init}
  59.     procedure InitGrowZone (alertid: integer);
  60.     begin
  61.         id := alertid;
  62.         SetGrowZone(@MyGrowZone);
  63.         gzh := nil;
  64.         lastgzh := nil;
  65.         GrowZoneIdle;
  66.     end;
  67.  
  68. {$S Term}
  69.     procedure FinishGrowZone;
  70.     begin
  71.         if gzh <> nil then begin
  72.             DisposHandle(gzh);
  73.             gzh := nil;
  74.         end;
  75.     end;
  76.  
  77. end.